package com.demo.cms.search;

import java.util.List;

import com.demo.cms.service.ArticleService;
import com.demo.search.support.SearchTaskSupport;

/**
 * 文章索引支撑类
 * @author ryuu.kk
 *
 */
public class ArticleSearchTaskSupport implements SearchTaskSupport {
	
	/**
	 * 支持类型
	 */
	private static final String SUPPORT_TYPE = "article";
	
	/**
	 * 文章服务
	 */
	private ArticleService articleService;
	
	@Override
	public boolean support(String type) {
		return SUPPORT_TYPE.equals(type);
	}

	@Override
	public Object getTarget(Long id) {
		// 取得带有文章内容的模型
		return articleService.query(id);
	}

	@Override
	public List<? extends Object> getTargetAll() {
		return articleService.findList(null, "");
	}

	public void setArticleService(ArticleService articleService) {
		this.articleService = articleService;
	}
}
